using UnityEngine;
using UnityEngine.UI;

public class Settings : MonoBehaviour
{
	private ASMRSwicher aSMRSwicher;

	private GameProperties gameProperties;

	[SerializeField]
	private GameObject SettingsPanel;

	[SerializeField]
	private Button soundSwicherButton;

	[SerializeField]
	private Button hapticSwicherButton;

	private void OnEnable()
	{
		if (!aSMRSwicher)
		{
			aSMRSwicher = GameObject.Find("Manager").GetComponent<ASMRSwicher>();
		}
		if (!gameProperties)
		{
			gameProperties = GameObject.Find("Manager").GetComponent<GameProperties>();
		}
		soundSwicherButton.GetComponent<Animator>().SetBool("on", gameProperties.IsSoundEnable());
		hapticSwicherButton.GetComponent<Animator>().SetBool("on", gameProperties.IsHapticEnable());
	}

	private void Start()
	{
		soundSwicherButton.onClick.AddListener(delegate
		{
			SoundClicked();
		});
		hapticSwicherButton.onClick.AddListener(delegate
		{
			HapticClicked();
		});
	}

	private void OnDestroy()
	{
		soundSwicherButton.onClick.RemoveAllListeners();
		hapticSwicherButton.onClick.RemoveAllListeners();
	}

	public void SoundClicked()
	{
		bool flag = !gameProperties.IsSoundEnable();
		gameProperties.SetSoundEnable(flag);
		soundSwicherButton.GetComponent<Animator>().SetBool("on", flag);
		aSMRSwicher.SwichSound(flag);
	}

	public void HapticClicked()
	{
		bool flag = !gameProperties.IsHapticEnable();
		gameProperties.SetHapticEnable(flag);
		hapticSwicherButton.GetComponent<Animator>().SetBool("on", flag);
		aSMRSwicher.SwichHaptic(flag);
	}
}
